/**
 * Copyright (c) 2017 ShopJsp. All Rights Reserved.
 * ============================================================================
 * 版权所有 2011 - 今 北京华宇盈通科技有限公司，并保留所有权利。
 * ----------------------------------------------------------------------------
 * 提示：在未取得SHOPJSP商业授权之前，您不能将本软件应用于商业用途，否则SHOPJSP将保留追究的权力。
 * ----------------------------------------------------------------------------
 * 官方网站：http://www.shopjsp.com
 * ============================================================================
 * @author 张丁方
 * @CreateTime 2017-3-31 13:29:52
 */
package com.hyyt.shopjsp.store.info.service.imp;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.hyyt.shopjsp.store.info.vo.ShopShopInfoVo;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.hyyt.shopjsp.store.info.dao.ShopShopInfoDAO;
import com.hyyt.shopjsp.store.info.pojo.ShopShopInfo;
import com.hyyt.shopjsp.store.info.service.IShopShopInfoService;

@Service
public class ShopShopInfoService implements IShopShopInfoService {
    private static  final Logger logger = Logger.getLogger(IShopShopInfoService.class);

    @Resource
    private ShopShopInfoDAO shopShopInfoDAO;

    /**
     * 保存SHOP_店铺信息
     *
     * @param shopShopInfo SHOP_店铺信息
     * @return 保存后的SHOP_店铺信息
     */
    @Override
    public void saveShopShopInfo(ShopShopInfo shopShopInfo) {
        shopShopInfoDAO.insert(shopShopInfo);
    }

    /**
     * 更新SHOP_店铺信息
     *
     * @param shopShopInfo SHOP_店铺信息
     * @return 更新后的SHOP_店铺信息
     */
    @Override
    public boolean updateShopShopInfo(ShopShopInfo shopShopInfo) {
    	boolean flag=false;
    	if(flag==false){
    		shopShopInfoDAO.update(shopShopInfo);
    		flag=true;
    	}
        return flag;
    }

    /**
     * 更新SHOP_店铺信息
     *
     * @param params SHOP_店铺信息
     * @return 更新后的SHOP_店铺信息
     */
    @Override
    public void updateShopShopInfoByShopInfoIds(Map<String, Object> params) {
        shopShopInfoDAO.update("updateShopShopInfoByShopInfoIds",params);
    }

    /**
     * 删除指定ID的SHOP_店铺信息
     *
     * @param id SHOP_店铺信息ID
     */
    @Override
    public void deleteShopShopInfo(Integer id) {
        shopShopInfoDAO.delete(id);
    }

    /**
     * 删除指定ID集合的SHOP_店铺信息
     *
     * @param ids SHOP_店铺信息ID集合
    */
    public void deleteShopShopInfo(Collection<Integer> ids){
        shopShopInfoDAO.batchDelete(ids);
    }

    /**
     * 根据ID加载一个SHOP_店铺信息
     *
     * @param id SHOP_店铺信息ID
     * @return SHOP_店铺信息
     */
    @Override
    public ShopShopInfo loadShopShopInfo(Integer id) {
        return shopShopInfoDAO.load(id);
    }

    /**
    * 查询所有的SHOP_店铺信息，通常有最多取30000条记录的限制
    *
    * @return 所有的SHOP_店铺信息，通常有最多取30000条记录的限制
    */
    @Override
    public List<ShopShopInfo> queryAllShopShopInfo() {
        return shopShopInfoDAO.queryAll();
    }

    /**
     * 查询SHOP_店铺信息
     *
     * @param params 查询参数，为key-value形式
     * @return SHOP_店铺信息集合
     */
    @Override
    public List<ShopShopInfo> queryShopShopInfo(Map<String, Object> params) {
        return shopShopInfoDAO.query(params);
    }

    /**
     * 查询SHOP_店铺信息
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return SHOP_店铺信息集合
     */
    @Override
    public List<ShopShopInfo> queryShopShopInfo(Map<String, Object> params, int startRow, int rowSize) {
        return shopShopInfoDAO.query(params, startRow, rowSize);
    }

    /**
     * 通过店铺客服查询SHOP_店铺信息
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return SHOP_店铺信息集合
     */
    @Override
    public List<ShopShopInfo> queryShopShopInfoForShopCustomerService(Map<String, Object> params, int startRow, int rowSize) {
        return shopShopInfoDAO.query("queryShopShopInfoForShopCustomerService",params, startRow, rowSize);
    }
    /**
     * 店铺客服中统计SHOP_店铺信息
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countForShopCustomerService(Map<String, Object> params) {
        return shopShopInfoDAO.count("countForShopCustomerService",params);
    }

    /**
     * 统计SHOP_店铺信息
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countShopShopInfo(Map<String, Object> params) {
        return shopShopInfoDAO.count(params);
    }


    /**
     * 查询店铺集合
     * @param params
     * @return
     */
	@Override
	public List<ShopShopInfo> queryShopInfoList(Map<String, Object> params) {
		return shopShopInfoDAO.query("queryshopInfoList",params);
	}

	/**
	 * 统计自营SHOP_店铺
	 * @param params
	 * @return
	 */
	@Override
	public int countSelfSupportShopInfo(Map<String, Object> params) {
		return shopShopInfoDAO.count("countSelfSupportShopInfo", params);
	}

	/**
	 * 查询自营SHOP_店铺集合
	 * @param params
	 * @param startRow
	 * @param rowSize
	 * @return
	 */
	@Override
	public List<ShopShopInfo> querySelfSupportShopInfoList(
			Map<String, Object> params, int startRow, int rowSize) {
		return shopShopInfoDAO.query("querySelfSupportShopInfoList", params, startRow, rowSize);
	}

	/**
	 * 查询店铺客户id
	 * @param params
	 * @return
	 */
	@Override
	public ShopShopInfo loadShopInfoByCustomerId(Map<String, Object> params) {
		return shopShopInfoDAO.load("loadShopinfoByCustomerId", params);
	}

    /**
     * 店铺销量排行统计
     * @param params
     * @param startRow
     * @param rowSize
     * @return
     */
    @Override
    public List<ShopShopInfoVo> queryShopSalesStatistics(Map<String, Object> params, int startRow, int rowSize) {
        return shopShopInfoDAO.query("queryShopSalesStatistics",params, startRow, rowSize);
    }

    /**
     * 导出店铺销量排行统计excel
     * @param params
     * @return
     */
    @Override
    public List<ShopShopInfoVo> queryShopSalesStatistics(Map<String, Object> params) {
        return shopShopInfoDAO.query("queryShopSalesStatistics",params);
    }
    /**
     * 店铺交易汇总查询集合
     * @param params
     * @param startRow
     * @param rowSize
     * @return
     */
    @Override
    public List<Map<String,Object>> queryShopTransactionSummary(Map<String, Object> params, int startRow, int rowSize){
        return shopShopInfoDAO.query("queryShopTransactionSummary",params,startRow,rowSize);
    }

    /**
     * 用于导出店铺交易汇总excel查询方法 （不带分页）
     * @param params
     * @return
     */
    @Override
    public List<Map<String,Object>> queryShopTransactionSummary(Map<String, Object> params){
        return shopShopInfoDAO.query("queryShopTransactionSummary",params);
    }
    /**
     * 店铺交易汇总查询数量
     * @param params
     * @return
     */
    @Override
    public int countShopTransactionSummary(Map<String, Object> params){
        return shopShopInfoDAO.count("countShopTransactionSummary",params);
    }

    /**
     * 保存审核店铺
     * @param params
     */
    @Override
    public boolean saveCheckShopInfo (Map <String , Object> params){
        boolean flag=false;
        if(flag==false){
            shopShopInfoDAO.update("saveCheckShopInfo",params);
            flag=true;
        }
        return flag;
    }

    /**
     * 查询SHOP_店铺信息 从店铺分类列表中查询关联的店铺信息
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return SHOP_店铺信息集合
     */
    @Override
    public List<ShopShopInfo> queryShopInfoByShopCategoryId(Map<String, Object> params, int startRow, int rowSize) {
        return shopShopInfoDAO.query("queryShopInfoByShopCategoryId",params, startRow, rowSize);
    }

    /**
     * 统计SHOP_店铺信息 从店铺分类列表中查询关联的店铺信息
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countShopInfoByShopCategoryId(Map<String, Object> params) {
        return shopShopInfoDAO.count("countShopInfoByShopCategoryId",params);
    }


}